<?php

namespace app\common\controller;


class Logined extends UnLogin {

    public $uid;
    public $user_info;

    public function initialize() {
        parent::initialize();
        $uid   = P('uid');
        $token = P('token');
        if ($this->ip == '127.0.0.1') {
            $uid = 1;
            $user_info = model('UserModel')->getAllUserInfo($uid);
            $this->uid       = $uid;
            $this->user_info = $user_info;
        } else {
            if (empty($uid) || empty($token)) {
                $this->retData(-1,'请先登录');
            }
            $check_token = model('TokenModel')->veriToken($uid, $token);
            if(empty($check_token)){
                $this->retData(-1,'没有登录');
            }
            $user_info = model('UserModel')->getAllUserInfo($uid);
            if($user_info['status'] == 0){
                $this->retData(-1,'账号已被冻结');
            }
            $this->user_info = $user_info;
            $this->uid       = $uid;
        }    
    }

    public function index() {
        return __CLASS__;
    }

}
